<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta content="noindex, nofollow" name="robots" />
	<link href="../css/fck_control.css" type="text/css" rel="stylesheet"/>
	<script src="common/fck_dialog_common.js" type="text/javascript"></script>
	<script type="text/javascript">
var dialog	= window.parent ;
var oEditor = dialog.InnerDialogLoaded() ;
var oDOM = oEditor.FCK.EditorDocument ;
var oActiveEl = dialog.Selection.GetSelectedElement() ;
var exist=false;
var defaultWidth=80;
var defaultFontSize=10;
window.onload = function()
{
	oEditor.FCKLanguageManager.TranslatePage(document) ;
	if ( oActiveEl && oActiveEl.tagName == 'INPUT' && oActiveEl.type == 'text' && !GetAttribute(oActiveEl,'macrotype') )
	{
		GetE('txtName').value	= oActiveEl.name ;
		GetE('txtId').value	= oActiveEl.id ;
		GetE('txtValue').value	= oActiveEl.value ;
		var fontsize=oActiveEl.style.fontSize;
		GetE('txtSize').value	= parseInt((fontsize==""?defaultFontSize:fontsize));
		var txtMax=GetAttribute( oActiveEl, 'maxLength' );
		txtMax=(txtMax==0?"":txtMax);
		GetE('txtMax').value	= txtMax ;
		var type = GetAttribute( oActiveEl, 'valuetype' );
		GetE('txtType').value	=  (!type?'character':type);
		var txtWidth=oActiveEl.style.width;
		GetE('txtWidth').value=parseInt((txtWidth==""?defaultWidth:txtWidth));
		GetE('underline').checked=GetAttribute(oActiveEl,'underline')==1 ;
	}
	else
	{
		if(oActiveEl){
			exist=true;
		}
		oActiveEl = null ;
	}
	dialog.SetOkButton( true ) ;
	dialog.SetAutoSize( true ) ;
	SelectField( 'txtName' ) ;
}
 
function Ok()
{
	if (GetE('txtName').value.Trim()=="")
	{
		alert(oEditor.FCKLang.Milan_NameEmpty);
		GetE('txtName').focus() ;
		return false ;
	}
	if(realLengthOverflow(GetE('txtName').value)){
		alert("名称不能超过30个字符！");
		GetE('txtName').focus() ;
		return false ;
	}
	if(fieldNameRegExp.test(GetE('txtName').value.Trim())){
		alert("名称不能带特殊字符！");
		GetE('txtName').focus() ;
		return false ;
	}	
	if((!oActiveEl||oActiveEl.name!=txtName.value)&&!vilidateWidgetName(oEditor.FCK.EditorDocument,GetE('txtName').value)){
		alert("名称“"+GetE('txtName').value+"”已存在，请重新命名！");
		return false;
	}
	if ( isNaN( GetE('txtWidth').value ) || GetE('txtWidth').value < 0 )
	{
		alert("宽度必须为大于0的数字！");
		GetE('txtWidth').focus() ;
		return false ;
	}
	if( isNaN( GetE('txtSize').value ) || GetE('txtSize').value < 0 )
	{
		alert("字体大小必须为大于0的数字！");
		GetE('txtSize').focus() ;
		return false ;
	}
	if ( isNaN( GetE('txtMax').value ) || GetE('txtMax').value < 0 )
	{
		alert(oEditor.FCKLang.Milan_MaxSizeError);
		GetE('txtMax').focus() ;
		return false ;
	}
	var valueType=GetE('txtType').value,value=GetE('txtValue').value;
	if(valueType=="number" &&value!=""&&!/^[-]?[\d]+(\.?[\d]+)?$/.test(value)){
		alert("初始值必须是数字！");GetE('txtValue').focus() ;
		return false;
	}else if(valueType=="money" &&value!=""&&!/^[\d]+(\.?[\d]{1,2})?$/.test(value)){
		alert("初始值必须是数字！且小数点后最多只能有两位小数！");GetE('txtValue').focus() ;
		return false;
	}
	if(value!=""&&GetE('txtMax').value!=""&&GetE('txtMax').value<value.length){
		alert("初始值长度不能大于最大字符数！");
		GetE('txtValue').focus() ;
		return false;
	}
	oEditor.FCKUndo.SaveUndoStep() ;
	createElementIfNoExist(exist,"INPUT",oActiveEl,oEditor);
	oActiveEl = CreateNamedElement( oEditor, oActiveEl, 'INPUT', 
		{name: GetE('txtName').value,
		 value:GetE('txtValue').value,
		 size:GetE("txtSize").value,
		 valuetype:valueType,
		 type: "text" } ) ;
	var txtWidth=GetE("txtWidth").value;
	oActiveEl.style.width=(txtWidth==""?defaultWidth:txtWidth)+'pt';
	SetAttribute( oActiveEl, 'id', GetE('txtId').value ) ;
	SetAttribute( oActiveEl, 'underline', GetE('underline').checked?1:0 ) ;
	var maxLength = GetE('txtMax').value;
	if(maxLength&&parseInt(maxLength)!=0){
		SetAttribute( oActiveEl, 'maxlength', maxLength ) ;
	}
	var fontsize=GetE("txtSize").value;
	oActiveEl.style.fontSize=(fontsize==""?defaultFontSize:fontsize)+'pt';
	oActiveEl.style.lineHeight =(fontsize==""?defaultFontSize:fontsize)+'pt';
	return true ;
}
 
	</script>
</head>
<body style="overflow:hidden;margin:0;padding:0;">
	<table class="control">
		<tr>
			<th>*<span fcklang="DlgTextType">Type</span>：</th>
			<td><select id="txtType">
					<option value="character" selected="selected"fcklang="DlgTextTypeChar">Character</option>
					<option value="number"fcklang="DlgTextTypeNum">Number</option>
					<option value="money"fcklang="DlgTextTypeMoney">Money</option>
					<!--option value="date"fcklang="DlgTextTypeDate">Date</option-->
				</select>
				<div style="display:none;">
			    	<span fcklang="DlgUniqueId">Unique Identifier</span><br />
					<input id="txtId" type="text" size="20" maxlength="20"/>
				</div>
			</td>
		</tr>
		<tr>
			<th>*<span fcklang="DlgTextName">Name</span>：</th>
			<td><input id="txtName" type="text" size="20" />
			<span style="display:block;color:#333;margin-top:5px;" fcklang="DlgNameRemind">输入提示</span></td>
		</tr>
		<tr>
			<th><span fcklang="DlgTextValue">Value</span>：</th>
			<td><input id="txtValue" type="text" size="25" /></td>
		</tr>
		<tr>
			<th><span fcklang="DlgTextareaCols">Width</span>：</th>
			<td><input id="txtWidth" type="text" size="5" value="80"/>&nbsp;pt</td>
		</tr>
		<tr>
			<th><span fcklang="DlgTextCharWidth">Character Size</span>：</th>
			<td><input id="txtSize" type="text" size="5" value="10"/>&nbsp;pt</td>
		</tr>
		<tr>
			<th><span fcklang="DlgTextMaxChars">Maximum Characters</span>：</th>
			<td><input id="txtMax" type="text" size="5" /></td>
		</tr>
		<tr>
			<th><span fcklang="DlgSelectUnderline">Underline</span>：</th>
			<td><input id="underline" type="checkbox">
			<span style="color:#333;margin-top:5px;" fcklang="DlgUnlineRemind">输入提示</span></td>
		</tr>
	</table>
</body>
</html>

